<Mcml
  xmlns="http://schemas.microsoft.com/2006/mcml"
  xmlns:cor="assembly://MSCorLib/System"
  xmlns:ds="PBDA://2734DC82-774D-4daa-A5AD-2838B5A58127/GPNVSCMD.do?cmd=LFILE;filename=Setup_DataSource.mcml"
  xmlns:addin="assembly://Microsoft.MediaCenter/Microsoft.MediaCenter.Hosting"

  xmlns:me="Me">
  <!--xmlns:addin="assembly://Microsoft.MediaCenter/Microsoft.MediaCenter.Hosting"-->

  <!-- Color -->
  <Color Name="TitleColor" Color="255,255,255"/>
  <Color Name="SubTitleColor" Color="255,255,255"/>
  <Color Name="DescriptionColor" Color="149,214,253"/>
  <!-- Font -->
  <Font Name="TitleFont" Font="Microsoft YaHei,28"/>
  <Font Name="SubTitleFont" Font="Microsoft YaHei,22"/>
  <Font Name="DescriptionFont" Font="Microsoft YaHei,18"/>
  <!-- Image -->
  <Image Name="Background" Image="PBDA://2734DC82-774D-4daa-A5AD-2838B5A58127/Microsoft.com/NV/Variable/MCE/Assets/Base64Binary/COMMON.BACKGROUND.PNG"/>
  <Image Name="Background1" Image="PBDA://2734DC82-774D-4daa-A5AD-2838B5A58127/Microsoft.com/NV/Variable/MCE/Assets/Base64Binary/bg2.PNG"/>
  <Image Name="Background2" Image="PBDA://2734DC82-774D-4daa-A5AD-2838B5A58127/Microsoft.com/NV/Variable/MCE/Assets/Base64Binary/bg2.PNG"/>
  <Image Name="ListFrame" Image="PBDA://2734DC82-774D-4daa-A5AD-2838B5A58127/Microsoft.com/NV/Variable/MCE/Assets/Base64Binary/sqs.png" />
  <Image Name="NofocusedBackground" Image="PBDA://2734DC82-774D-4daa-A5AD-2838B5A58127/Microsoft.com/NV/Variable/MCE/Assets/Base64Binary/COMMON.BUTTON.FIRSTRUN.DORMANT.FULL.PNG"/>
  <Image Name="FocusedBackground" Image="PBDA://2734DC82-774D-4daa-A5AD-2838B5A58127/Microsoft.com/NV/Variable/MCE/Assets/Base64Binary/COMMON.BUTTON.LEFT.FOCUS.PNG"/>
  <Image Name="PressedBackground" Image="PBDA://2734DC82-774D-4daa-A5AD-2838B5A58127/Microsoft.com/NV/Variable/MCE/Assets/Base64Binary/COMMON.BUTTON.LEFT.FOCUSOVERLAY.PNG"/>
  <Image Name="HoverBackground" Image="PBDA://2734DC82-774D-4daa-A5AD-2838B5A58127/Microsoft.com/NV/Variable/MCE/Assets/Base64Binary/COMMON.BUTTON.LEFT.FOCUS.PNG"/>
  <Image Name="WinLogo" Image="PBDA://2734DC82-774D-4daa-A5AD-2838B5A58127/Microsoft.com/NV/Variable/MCE/Assets/Base64Binary/MEDIACENTERLOGO.png"/>
  <Image Name="TopRest" Image="PBDA://2734DC82-774D-4daa-A5AD-2838B5A58127/Microsoft.com/NV/Variable/MCE/Assets/Base64Binary/AUTOSCROLL.CHEVRON.TOP.REST.PNG"/>
  <Image Name="BottomRest" Image="PBDA://2734DC82-774D-4daa-A5AD-2838B5A58127/Microsoft.com/NV/Variable/MCE/Assets/Base64Binary/AUTOSCROLL.CHEVRON.BOTTOM.REST.PNG"/>


  <UI Name="ChooseCity" BaseUI="ds:Channel">
    <Properties>
      <cor:String Name="Title" cor:String="Digital Antenna(DMB-TH PBDA)诊断"/>
      <cor:String Name="SubTitle" cor:String="城市选择"/>
      <cor:String Name="Description" cor:String="为了最快地接收到中国无线地面数字电视信号和方便调节电视天线的方向和角度。"/>
      <cor:String Name="Description2" cor:String="请选择所在城市："/>
      <cor:String Name="ChosenItem" cor:String="null"/>
      <cor:String Name="ChosenCityCN" cor:String="null"/>
    </Properties>
    <Locals>
	<addin:AddInHost Name="AddInHost"/>
      <Command Name="Back" Description="上一步"/>
      <Command Name="Next" Description="下一步"/>
      <Command Name="Skip" Description="跳过"/>

    </Locals>
    <Rules>
      <Changed Source="[Skip.Invoked]">
        <Actions>
         <Invoke Target="[AddInHost.ApplicationContext.CloseApplication]"/>
        </Actions>
      </Changed>
      <Changed Source="[Back.Invoked]">
        <Actions>
          <Navigate Source="PBDA://2734DC82-774D-4daa-A5AD-2838B5A58127/GPNVSCMD.do?cmd=LFILE;filename=Setup.mcml"/>
        </Actions>
      </Changed>
      <Changed Source="[Next.Invoked]">
        <Conditions>
          <Equality Source="[ChosenItem]" Value="null" ConditionOp="NotEquals"/>
        </Conditions>
        <Actions>
          <Navigate Source="PBDA://2734DC82-774D-4daa-A5AD-2838B5A58127/GPNVSCMD.do?cmd=LFILE;filename=Setup_Signal.mcml#SearchSignal" CityId="[ChosenItem]" CitynameCN="[ChosenCityCN]"/>
        </Actions>
      </Changed>
      <Changed Source="[Next.Invoked]">
        <Conditions>
          <Equality Source="[ChosenItem]" Value="null"/>
        </Conditions>
        <Actions>
          <Set Target="[CurrentCity.Content]" Value="请选择城市！"/>
        </Actions>
      </Changed>
      <Default Target="[ChannelChoice.ChosenIndex]" Value="0">
        <Actions>
          <Set Target="[ChosenItem]" Value="[ChannelChoice.Chosen!PropertySet.#Id!cor:String]" />
          <Set Target="[ChosenCityCN]" Value="[ChannelChoice.Chosen!PropertySet.#Title!cor:String]" />
          <Set Target="[CurrentCity.Content]" Value="[ChosenCityCN]"/>
        </Actions>
      </Default>
      <Changed Source="[ChannelChoice.ChosenIndex]">
        <Actions>
          <Set Target="[ChosenItem]" Value="[ChannelChoice.Chosen!PropertySet.#Id!cor:String]" />
          <Set Target="[ChosenCityCN]" Value="[ChannelChoice.Chosen!PropertySet.#Title!cor:String]" />
          <Set Target="[CurrentCity.Content]" Value="[ChosenCityCN]"/>
          <Invoke Target="[CmdBtn.NavigateInto]"/>
        </Actions>
      </Changed>
      <Rule>
        <Actions>
          <Invoke Target="[CmdBtn.NavigateInto]"/>
          <Invoke Target="[Scroller.NavigateInto]"/>
        </Actions>
      </Rule>
    </Rules>
    <Content>
      <Panel>
        <Children>
          <Panel Layout="Anchor" Margins="0,46,100,20">
            <Children>
              <Text Name="TitleText" Content="[Title]" Color="color://me:TitleColor" Font="font://me:TitleFont">
                <LayoutInput>
                  <AnchorLayoutInput Left="Parent,.150" Top="Parent,0,0"/>
                </LayoutInput>
              </Text>
              <Graphic Content="image://me:WinLogo" MaximumSize="251,36" MinimumSize="251,36">
                <LayoutInput>
                  <AnchorLayoutInput Right="Parent,1,-30" Top="Parent,0,20"/>
                </LayoutInput>
              </Graphic>
              <Text Name="SubTitleText" Content="[SubTitle]" Color="color://me:SubTitleColor" Font="font://me:SubTitleFont">
                <LayoutInput>
                  <AnchorLayoutInput Left="Parent,0.155" Right="Parent,0.7" Top="TitleText,1,45"/>
                </LayoutInput>
              </Text>
              <Text Name="DescriptionText" Content="[Description]" Color="color://me:DescriptionColor"  Font="font://me:DescriptionFont">
                <LayoutInput>
                  <AnchorLayoutInput Left="Parent,0.155" Top="SubTitleText,1,16"/>
                </LayoutInput>
              </Text>
              <Text Name="Description2Text" Content="[Description2]" Color="color://me:DescriptionColor"  Font="font://me:DescriptionFont">
                <LayoutInput>
                  <AnchorLayoutInput Left="Parent,0.155" Top="DescriptionText,1,16"/>
                </LayoutInput>
              </Text>

              <Panel Name="Contents" Layout="Anchor" >
                <LayoutInput>
                  <AnchorLayoutInput Left="Parent,0.155"  Top="Description2Text,1,18"/>
                </LayoutInput>
                <Children>
                  <me:CityScroller Name="Scroller" ChannelList="[ChannelChoice]" FocusOrder="0"/>
                  <Text Name="CurrentCity"  Color="color://me:DescriptionColor"  Font="font://me:DescriptionFont">
                    <LayoutInput>
                      <AnchorLayoutInput Left="Scroller,1,20" Top="Scroller,0"/>
                    </LayoutInput>
                  </Text>
                </Children>
              </Panel>
              <Panel Name="CmdBtn">
                <LayoutInput>
                  <AnchorLayoutInput Right="Parent,0.932"  Bottom="Parent,1,-5"/>
                </LayoutInput>
                <Layout>
                  <FlowLayout StripAlignment="Far" Orientation="Horizontal" Spacing="20,0"/>
                </Layout>
                <Children>
                  <me:Button Name="BackButton" Command="[Back]" FocusOrder="1"/>
                  <me:Button Name="NextButton" Command="[Next]" FocusOrder="0"/>
                  <me:Button Name="SkipButton" Command="[Skip]" FocusOrder="2"/>
                </Children>
              </Panel>
            </Children>
          </Panel>
          <me:Background Name="Background"/>
        </Children>
      </Panel>
    </Content>
  </UI>

  <UI Name="CityScroller">
    <Properties>
      <Choice Name="ChannelList" Choice="$Required"/>
    </Properties>
    <Locals>
      <!-- The ScrollingHandler which reacts to user keyboard input. -->
      <!-- NOTE: HandlerStage must be "Bubbled."                     -->
      <ScrollingHandler Name="ScrollingHandler" HandlerStage="Bubbled"/>

      <!-- ScrollingData contains many ways to customize how scrolling -->
      <!-- should behave. It has methods to change the current scroll  -->
      <!-- position and it also reports the position. In this case,    -->
      <!-- the default values are used for the sample.                 -->
      <ScrollingData Name="ScrollingData"/>
      <IntRangedValue Name="CurrentIndex" Value="1"/>
    </Locals>
    <Rules>
      <!-- Give ScrollingData to ScrollingHandler. -->
      <Default Target="[ScrollingHandler.ScrollingData]" Value="[ScrollingData]"/>
      <!-- Give Repeater to ScrollingData. -->
      <Default Target="[ScrollingData.Repeater]" Value="[ListRepeater]"/>

      <!-- Bind the current page from the scrolling data to our display. -->
      <Binding Source="[CurrentIndex.Value]"
               Target="[CurrentItem.Content]">
        <Transformer>
          <FormatTransformer Format="{0}"/>
        </Transformer>
      </Binding>

      <!-- Bind the total page count from the scrolling data to our display. -->
      <Binding Source="[ChannelList.Options.Count]"
               Target="[TotalItems.Content]">
        <Transformer>
          <FormatTransformer Format="{0}"/>
        </Transformer>
      </Binding>

    </Rules>
    <Content>
      <Panel Layout="Anchor">
        <Children>
          <Graphic Name="CityList" Content="image://me:ListFrame" MaximumSize="452,188" >
            <Children>
              <!-- The Scroller. It referrs to the ScrollingData too. -->
              <Scroller Orientation="Vertical" FadeSize="1" ScrollingData="[ScrollingData]" Padding="2,0,0,0">
                <Children>
                  <!-- The Repeater. A direct child of the Scroller. -->
                  <Repeater Name="ListRepeater" Source="[ChannelList.Options]">
                    <Layout>
                      <FlowLayout Orientation="Vertical" Spacing="0,0"
                                  ItemAlignment="Center" StripAlignment="Near"/>
                    </Layout>
                    <Content>

                      <!-- Repeating out the items. -->
                      <me:ListItem Choice="[ChannelList]" Text="[RepeatedItem!PropertySet.#Title!cor:String]" Index="[RepeatedItemIndex]" CurrentIndex="[CurrentIndex]" ImgMinimumSize="450,47" ImgMaximumSize="450,47"/>
                    </Content>
                  </Repeater>
                </Children>
              </Scroller>
            </Children>
          </Graphic>
          <Panel Layout="HorizontalFlow">
            <LayoutInput>
              <AnchorLayoutInput Right="CityList,1" Top="CityList,1,5"/>
            </LayoutInput>
            <Children>
              <Text Name="CurrentItem" Font="font://me:DescriptionFont" Color="color://me:DescriptionColor"/>
              <Text Name="Slash" Content="/" Font="font://me:DescriptionFont" Color="color://me:DescriptionColor"/>
              <Text Name="TotalItems" Font="font://me:DescriptionFont" Color="color://me:DescriptionColor"/>
              <Graphic Name="TopRestGr" Content="image://me:TopRest"  MaximumSize="35,30" MinimumSize="35,30"/>
              <Graphic Name="BottomRestGr" Content="image://me:BottomRest" MaximumSize="35,30" MinimumSize="35,30"/>
            </Children>
          </Panel>
        </Children>
      </Panel>
    </Content>
  </UI>

  <!-- A UI that is key-interactive for demonstrating the Scroller. -->
  <UI Name="ListItem">
    <Properties>
      <Choice Name="Choice" Choice="$Required"/>
      <cor:String Name="Text" String="$Required"/>
      <Index Name="Index" Index="$Required" />
      <IntRangedValue Name="CurrentIndex" IntRangedValue="$Required"/>
      <Size Name="ImgMinimumSize"/>
      <Size Name="ImgMaximumSize"/>
      <!-- Background color properties. -->
      <Color Name="BackgroundColor" Color="DimGray"/>
      <Color Name="BackgroundFocusedColor" Color="DarkGray"/>
      <Color Name="BackgroundHoverColor" Color="PaleGoldenrod"/>
      <Color Name="BackgroundPressedColor" Color="White"/>

      <!-- Label color properties. -->
      <Color Name="LabelColor" Color="White"/>
      <Color Name="LabelFocusedColor" Color="White"/>
      <Color Name="LabelHoverColor" Color="DimGray"/>
      <Color Name="LabelPressedColor" Color="Black"/>

      <!-- Label font property. -->
      <Font Name="LabelFont" Font="Microsoft YaHei,16"/>
    </Properties>
    <Locals>
      <ClickHandler Name="Clicker"/>
     
    </Locals>
    <Rules>
      <Binding Target="[Accessible.IsPressed]" Source="[Clicker.Clicking]" />
      <Binding Target="[Accessible.IsFocusable]" Source="[Input.KeyInteractive]" />
      <Binding Target="[Accessible.IsFocused]" Source="[Input.KeyFocus]" />
      <Default Target="[Accessible.Role]" Value="PushButton" />
      <Default Target="[Input.MakeTopmostOnFocus]" Value="true" />
      <Default Target="[Input.KeyInteractive]" Value="true" />

      <Changed Source="[Choice.ChosenIndex]" InitialEvaluate="true">
        <Conditions>
          <Equality Source="[Choice.ChosenIndex]" Value="[Index.SourceValue]"/>
        </Conditions>
        <Actions>
          <Set Target="[Label.Color]" Value="[BackgroundHoverColor]"/>
          <!--<Set Target="[Background.Content]" Value="[LabelHoverColor]"/>-->
        </Actions>
      </Changed>

      <Condition Source="[Input.KeyFocus]" SourceValue="true">
        <Actions>
          <Set Target="[Background.Content]" Value="image://me:FocusedBackground"/>
          <Set Target="[Label.Color]" Value="[LabelFocusedColor]"/>
          <Set Target="[CurrentIndex.Value]" Value="[Index.SourceValue]">
            <Transformer>
              <MathTransformer AddInt="1"/>
            </Transformer>
          </Set>
          <!--<Set Target="[Background.Content]" Value="[BackgroundFocusedColor]"/>-->
        </Actions>
      </Condition>
      <Condition Source="[Input.KeyFocus]" SourceValue="false">
        <Actions>
          <Set Target="[Background.Content]" Value="null"/>
        </Actions>
      </Condition>
      <Condition Source="[Clicker.Clicking]" SourceValue="true">
        <Actions>
          <Set Target="[Label.Color]" Value="[LabelPressedColor]"/>
          <!--<Set Target="[Background.Content]" Value="[BackgroundPressedColor]"/>-->
          <Set Target="[Choice.ChosenIndex]" Value="[Index.SourceValue]" />
          <Set Target="[Background.Content]" Value="image://me:PressedBackground"/>
          
        </Actions>
      </Condition>
    </Rules>
    <Content>
      <Graphic Name="Background" MaximumSize="[ImgMaximumSize]"     MinimumSize="[ImgMinimumSize]" Padding="10,6,10,0"  >
        <Layout>
          <FlowLayout Orientation="Horizontal" ItemAlignment="Center" StripAlignment="Near"/>
        </Layout>
        <Children>
          <Text Name="Label" Content="[Text]" Font="[LabelFont]"  Color="[LabelColor]"/>

        </Children>
      </Graphic>
    </Content>
  </UI>
  
  <UI Name="Background">
    <Content>
      <Panel Layout="Anchor">
        <Children>
          <Graphic Content="image://me:Background1" Alpha="1" MaximumSize="0,110" MinimumSize="0,110" >
            <LayoutInput>
              <AnchorLayoutInput Top="Parent,0"/>
            </LayoutInput>
          </Graphic>
          <Graphic Content="image://me:Background2" Alpha="1" MaximumSize="0,110" MinimumSize="0,110" >
            <LayoutInput>
              <AnchorLayoutInput Bottom="Parent,1"/>
            </LayoutInput>
          </Graphic>
          <Graphic Content="image://me:Background" Layout="Fill" Alpha="1"/>

        </Children>
      </Panel>
    </Content>
  </UI>
  <UI Name="Button">
    <Properties>
      <!-- Command is a required parameter. -->
      <ICommand Name="Command" ICommand="$Required"/>

      <!-- Background color properties. -->
      <!--<Color Name="BackgroundColor" Color="DimGray"/>
      <Color Name="BackgroundFocusedColor" Color="DarkGray"/>
      <Color Name="BackgroundHoverColor" Color="PaleGoldenrod"/>
      <Color Name="BackgroundPressedColor" Color="White"/>-->

      <!-- Label color properties. -->
      <Color Name="LabelColor" Color="White"/>
      <Color Name="LabelFocusedColor" Color="White"/>
      <Color Name="LabelHoverColor" Color="DimGray"/>
      <Color Name="LabelPressedColor" Color="Black"/>

      <!-- Label font property. -->
      <Font Name="LabelFont" Font="Microsoft YaHei,16"/>
    </Properties>

    <Locals>

      <!-- React to "click" input. -->
      <ClickHandler Name="Clicker"/>

    </Locals>

    <Rules>
      <Binding Target="[Accessible.Name]" Source="[Command.Description]" />
      <Binding Target="[Accessible.IsFocusable]" Source="[Input.KeyInteractive]" />
      <Binding Target="[Accessible.IsFocused]" Source="[Input.KeyFocus]" />
      <Default Target="[Accessible.DefaultAction]" Value="Press" />
      <Default Target="[Accessible.DefaultActionCommand]" Value="[Command]" />
      <Default Target="[Accessible.Role]" Value="PushButton" />
      <Default Target="[Input.MakeTopmostOnFocus]" Value="true" />
      <Default Target="[Input.KeyInteractive]" Value="true" />

      <!-- The command description is displayed by the text box. A  -->
      <!-- binding is used in case the description changes at       -->
      <!-- runtime.                                                 -->
      <Binding Source="[Command.Description]" Target="[Label.Content]"/>

      <Binding Source="[Command]" Target="[Clicker.Command]"/>

      <!-- Change color on click. -->
      <Condition Source="[Clicker.Clicking]" SourceValue="true">
        <Actions>
          <Set Target="[Background.Content]" Value="image://me:PressedBackground"/>
          <Set Target="[Label.Color]" Value="[LabelPressedColor]"/>
        </Actions>
      </Condition>

      <!-- Change color on mouse focus. -->
      <Condition Source="[Input.MouseFocus]" SourceValue="true">
        <Actions>
          <Set Target="[Background.Content]" Value="image://me:HoverBackground"/>
          <Set Target="[Label.Color]" Value="[LabelHoverColor]"/>
        </Actions>
      </Condition>
      <!-- Change color on key focus. -->
      <Condition Source="[Input.KeyFocus]" SourceValue="true">
        <Actions>
          <Set Target="[Background.Content]" Value="image://me:FocusedBackground"/>
          <Set Target="[Label.Color]" Value="[LabelFocusedColor]"/>
        </Actions>
      </Condition>
    </Rules>
    <Content>

      <!-- Solid background color. -->
      <Graphic Name="Background" Content="image://me:NofocusedBackground" Layout="Center" MaximumSize="166,30" MinimumSize="166,30">
        <Children>
          <!-- The label to display. -->
          <Text Name="Label" Color="[LabelColor]" Font="[LabelFont]"/>
        </Children>
      </Graphic>
    </Content>
  </UI>
</Mcml>
